package com.finger.crowd.service.api.impl;

import com.finger.crowd.entity.po.MemberPO;
import com.finger.crowd.entity.po.MemberPOExample;
import com.finger.crowd.mapper.MemberPOMapper;
import com.finger.crowd.service.api.MemberService;
import com.finger.crowd.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service
public class MemberServiceImpl implements MemberService {
    @Autowired
    private MemberPOMapper memberPOMapper;

    public ResultEntity<MemberPO> login(String loginAcct) {
        MemberPOExample memberPOExample = new MemberPOExample();

        MemberPOExample.Criteria criteria = memberPOExample.createCriteria();

        criteria.andLoginacctEqualTo(loginAcct);

        List<MemberPO> memberPOS = memberPOMapper.selectByExample(memberPOExample);

        MemberPO memberPO = memberPOS.get(0);

        return ResultEntity.successWithData(memberPO);

    }

    public void saveMember(MemberPO memberPO) {
        memberPOMapper.insertSelective(memberPO);
    }
}
